Skip to content

Conversation

@gretel
Copy link

@gretel gretel commented Nov 6, 2025

Add locale fallback logic to support regional locale variants (e.g., de-DE, de_DE) that fall back to base locale (de) when exact match is not found.

This fixes an issue where German translations were not loading in Scratch environments that use locale codes like 'de-DE' instead of just 'de'. The setupTranslations() function now:

  1. Checks for exact locale match first (e.g., 'de-DE')
  2. Falls back to base locale if no exact match (e.g., 'de-DE' -> 'de')
  3. Handles both hyphen and underscore separators ('de-DE' and 'de_DE')

Tested with:

  • German (de-DE, de_DE) -> successfully loads 'de' translations
  • Japanese and other existing locales continue to work
  • English fallback remains unchanged

Add locale fallback logic to support regional locale variants (e.g.,
de-DE, de_DE) that fall back to base locale (de) when exact match
is not found.

This fixes an issue where German translations were not loading in
Scratch environments that use locale codes like 'de-DE' instead of
just 'de'. The setupTranslations() function now:

1. Checks for exact locale match first (e.g., 'de-DE')
2. Falls back to base locale if no exact match (e.g., 'de-DE' -> 'de')
3. Handles both hyphen and underscore separators ('de-DE' and 'de_DE')

Tested with:
- German (de-DE, de_DE) -> successfully loads 'de' translations
- Japanese and other existing locales continue to work
- English fallback remains unchanged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant